﻿using System;
using System.Collections.Generic;
using System.Text;
using SwinGame;

namespace SurvivalNN.src
{
    class PropModel :IPropModel , IEntitySubModel
    {

        const float SPEED = 100.0f;

        PropType _propType = PropType.SOURCE_FOOD;
        public PropType PropType { set { _propType = value; } get { return _propType; } }

        ////////////
        //Position// 
        ////////////
        Vector _position = new Vector();

        public Vector Position
        {
            get { return _position; }
            set
            {
                if (_position != value)
                {
                    PositionChangeHandler(this, new PositionChangeEvent(_position, value));
                    _position = value;
                }
            }
        }

        //////////////////
        //Event Handlers// 
        //////////////////
        public event EventHandler<PositionChangeEvent> PositionChangeHandler;

        //////////////////
        //Event Reaction// 
        //////////////////
        public void MovePositionResponse(object o, MovePropEventArgs eventargs)
        {

            if (eventargs._isRelative)
            {
                Position = new Vector { X = Position.X + eventargs._v.X*SPEED, Y = Position.Y + eventargs._v.Y*SPEED };
            }
            else
            {
                Position = eventargs._v;
            }
        }
    }
}
